home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume30 / qdos_utils / part01 next >
Encoding:
Text File  |  1992-07-06  |  11.7 KB  |  442 lines

  1. Newsgroups: comp.sources.misc
  2. From: v882022@si.hhs.nl (Erik Slagter)
  3. Subject:  v30i100:  qdos_utils - Sinclair QL (QDOS) utility sources, Part01/01
  4. Message-ID: <1992Jul6.155616.6628@sparky.imd.sterling.com>
  5. X-Md4-Signature: 5d9407f75b32f4d7a9956c3c4029cbf0
  6. Date: Mon, 6 Jul 1992 15:56:16 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: v882022@si.hhs.nl (Erik Slagter)
  10. Posting-number: Volume 30, Issue 100
  11. Archive-name: qdos_utils/part01
  12. Environment: Sinclair QL or Atari w/QDOS
  13.  
  14. I have written some programs for the Sinclair QL computer / Atari computer
  15. with Qdos that may be of interest to other QL users.
  16.  
  17. This package consists of the following sources:
  18.  
  19. du.c        a unix-like du for level II device drivers (e.g. harddisks)
  20. more.asm    a very simple "more" variant for Qdos. Very fast though!
  21. unquill.c    convert a quill document into human-readable text.
  22.  
  23. #! /bin/sh
  24. # This is a shell archive.  Remove anything before this line, then feed it
  25. # into a shell via "sh file" or similar.  To overwrite existing files,
  26. # type "sh file -c".
  27. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  28. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  29. # Contents:  du.c more.asm unquill.c
  30. # Wrapped by kent@sparky on Mon Jul  6 10:50:02 1992
  31. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  32. echo If this archive is complete, you will see the following message:
  33. echo '          "shar: End of archive."'
  34. if test -f 'du.c' -a "${1}" != "-c" ; then 
  35.   echo shar: Will not clobber existing file \"'du.c'\"
  36. else
  37.   echo shar: Extracting \"'du.c'\" \(2883 characters\)
  38.   sed "s/^X//" >'du.c' <<'END_OF_FILE'
  39. X#include <stdio.h>
  40. X#include <errno.h>
  41. X#include <fido.h>
  42. X#include <qdos.h>
  43. X#include <ctype.h>
  44. X#include <time.h>
  45. X#include <dirent.h>
  46. X
  47. Xtypedef unsigned char       u_char;
  48. Xtypedef unsigned short  int u_short;
  49. Xtypedef unsigned long   int u_long;
  50. Xtypedef unsigned        int u_int;
  51. X
  52. X/*
  53. X    du.c 1.00 copyleft 1992 Erik Slagter (v882022@si.hhs.nl)
  54. X    This source may be distributed and modified freely if this message stays
  55. X    intact.
  56. X
  57. X    compile with c68k 2.00 or higher.
  58. X
  59. X    usage: ex du;"[-[sabkm]] {directory}"
  60. X
  61. X    flags:
  62. X
  63. X    -s short; do not output directory names
  64. X    -a all  ; output all file names and sizes
  65. X    -b bytes; output in bytes
  66. X    -k kbyte; output in kilobytes
  67. X    -m mega ; output in megabytes
  68. X
  69. X    multiple file and directory names and wildcards may be supplied
  70. X
  71. X    extremely useful in conjunction with harddisk or level II device driver.
  72. X
  73. X    Modification history of du
  74. X
  75. X    1.00: 920410:   First version
  76. X
  77. X*/
  78. X
  79. Xstatic  u_char  format          = 10;
  80. Xstatic  u_char  which           = 1;
  81. Xchar    _prog_name[]            = "du";
  82. Xlong    _mneed                  = 16384;
  83. Xstatic  u_char *_version        = "1.00";
  84. Xstatic  u_char *sccs            = "(#)du.c 1.01 920327 Qdos Minerva C68 2.00\n";
  85. X
  86. X#define oops(s) (perror(s), exit(ERR_BP))
  87. X
  88. Xu_int count(dir)
  89. Xu_char *dir;
  90. X{
  91. X    chanid_t    chanid;
  92. X    struct      qdirect qd;
  93. X    u_char      tmp[1024];
  94. X    u_char      file[1024];
  95. X    u_int       total = 0;
  96. X
  97. X    sprintf(tmp, "%s*", dir);
  98. X
  99. X    chanid = open_qdir(dir);
  100. X    while(read_qdir(chanid, tmp, file, &qd, 0))
  101. X        if(qd.d_type == QF_DIR_TYPE)
  102. X            total += count(file);
  103. X    io_close(chanid);
  104. X
  105. X    chanid = open_qdir(dir);
  106. X    while(read_qdir(chanid, tmp, file, &qd, 0))
  107. X        if(qd.d_type != QF_DIR_TYPE)
  108. X        {
  109. X            total += qd.d_length;
  110. X            if(which > 1)
  111. X                printf("%5d %s\n", qd.d_length >> format, file);
  112. X        }
  113. X    io_close(chanid);
  114. X
  115. X    if(which)
  116. X        printf("%5d %s\n", total >> format, *dir ? dir : ".");
  117. X
  118. X    return(total);
  119. X}
  120. X
  121. Xlong main(argc, argv)
  122. Xint argc;
  123. Xchar **argv;
  124. X{
  125. X    u_int   total = 0;
  126. X    u_int   dirs  = 0;
  127. X
  128. X    while(*++argv)
  129. X        if(argv[0][0] == '-')
  130. X            switch(argv[0][1])
  131. X            {
  132. X                case('s'):
  133. X                    which   = 0;    break;
  134. X                case('a'):
  135. X                    which   = 2;    break;
  136. X                case('b'):
  137. X                    format  = 0;    break;
  138. X                case('k'):
  139. X                    format  = 10;   break;
  140. X                case('m'):
  141. X                    format  = 20;   break;
  142. X                default:
  143. X                    fprintf(stderr, "usage: %s [-[sabkm]] {directory}\n", _prog_name);
  144. X                    exit(ERR_BP);
  145. X            }
  146. X        else
  147. X            total += count(*argv), dirs++;
  148. X
  149. X    if(!dirs)
  150. X        total = count("");
  151. X
  152. X    if((dirs > 1) || !which)
  153. X        printf("Total %5d\n", total >> format);
  154. X}
  155. X
  156. END_OF_FILE
  157.   if test 2883 -ne `wc -c <'du.c'`; then
  158.     echo shar: \"'du.c'\" unpacked with wrong size!
  159.   fi
  160.   # end of 'du.c'
  161. fi
  162. if test -f 'more.asm' -a "${1}" != "-c" ; then 
  163.   echo shar: Will not clobber existing file \"'more.asm'\"
  164. else
  165.   echo shar: Extracting \"'more.asm'\" \(4929 characters\)
  166.   sed "s/^X//" >'more.asm' <<'END_OF_FILE'
  167. X*! -errors ram1_more_list -nolink
  168. X*
  169. X*        Copyleft 1990-1992 Erik Slagter (v882022@si.hhs.nl) 
  170. X*        THis source may be distributed and modified freely if this message
  171. X*        stays intact.
  172. X*
  173. X*        more - version 2
  174. X*
  175. X*        assemble with GST macro assembler. Does not need to be linked.
  176. X*        Applies some macros that may not be in your library:
  177. X* 
  178. X*        - qdos
  179. X*        - call
  180. X*
  181. X*        These macros are very easy to implement though.
  182. X*
  183. X*        usage: ex more,inputfile[,outputdevice]
  184. X*    
  185. X*        include  win1_asm_include_macro_inc
  186. X*        include  win1_asm_include_equ_h
  187. X*
  188. X         offset   0
  189. X*
  190. Xbuffer   ds.w     1
  191. X         ds.b     8192
  192. Xfilelen  ds.l     1
  193. Xoffset   ds.l     1
  194. Xproffs   ds.l     1
  195. Xblock    ds.w     4
  196. Xstack    ds.b     256
  197. Xlen      ds.w     1
  198. X         data     len
  199. X*
  200. X         section  code
  201. X*
  202. X         bra.s    main
  203. X         dc.w     $4afb,$4afb,$4afb
  204. X         string$  {'More'}
  205. Xname     string$  {' More '}
  206. Xguard    string$  {'scr_498x224a6x30'}
  207. Xcon      string$  {'con_486x212a8x41'}
  208. Xbar      string$  {'scr_10x212a493x41'}
  209. X*
  210. Xmain     add.l    a4,a6
  211. X         moveq    #err.bp,d0
  212. X         cmp.w    #1,(a7)+
  213. X         bne      rjob
  214. X*
  215. X         move.l   (a7)+,a3          input channel
  216. X         tst.w    (a7)+
  217. X         bne      rjob
  218. X*
  219. X         move.w   #6,block+0(a6)
  220. X         clr.w    block+2(a6)
  221. X         clr.w    block+4(a6)
  222. X         clr.w    block+6(a6)
  223. X*
  224. X         clr.l    filelen(a6)
  225. X         clr.l    offset(a6)
  226. X         moveq    #endless,d3
  227. X         sub.w    #64,a7
  228. X         move.l   a3,a0
  229. X         move.l   a7,a1
  230. X         moveq    #64,d2
  231. X         qdos     fs.headr
  232. X         tst.l    d0
  233. X         bmi.s    nohead
  234. X         move.l   (a7),d1
  235. X         divu     #210,d1
  236. X         ext.l    d1
  237. X         move.l   d1,filelen(a6)
  238. Xnohead   add.w    #64,a7
  239. X*
  240. X         lea      guard,a0
  241. X         moveq    #myself,d1
  242. X         moveq    #new,d3
  243. X         qdos     io.open
  244. X         tst.l    d0
  245. X         bmi      rjob
  246. X         moveq    #endless,d3
  247. X         moveq    #7,d1
  248. X         moveq    #1,d2
  249. X         qdos     sd.bordr
  250. X         moveq    #7,d1
  251. X         qdos     sd.setpa
  252. X         qdos     sd.setst
  253. X         moveq    #0,d1
  254. X         qdos     sd.setin
  255. X         moveq    #86,d1
  256. X         qdos     sd.setpa
  257. X         qdos     sd.setst
  258. X         qdos     sd.clear
  259. X         moveq    #37,d1
  260. X         qdos     sd.tab
  261. X         moveq    #7,d1
  262. X         qdos     sd.setst
  263. X         lea      name,a1
  264. X         call     ut.mtext
  265. X*
  266. X         lea      con,a0
  267. X         moveq    #myself,d1
  268. X         moveq    #new,d3
  269. X         qdos     io.open           console
  270. X         tst.l    d0
  271. X         bmi      rjob
  272. X         move.l   a0,a4
  273. X         moveq    #4,d1
  274. X         moveq    #1,d2             border
  275. X         moveq    #endless,d3
  276. X         qdos     sd.bordr
  277. X         moveq    #7,d1
  278. X         qdos     sd.setin          ink
  279. X         moveq    #0,d1
  280. X         qdos     sd.setpa
  281. X         qdos     sd.setst
  282. X*
  283. X         lea      bar,a0
  284. X         moveq    #myself,d1
  285. X         moveq    #new,d3
  286. X         qdos     io.open           scroll bar
  287. X         tst.l    d0
  288. X         bmi      rjob
  289. X         move.l   a0,a5
  290. X         qdos     sd.clear
  291. X         moveq    #4,d1
  292. X         moveq    #1,d2             border
  293. X         moveq    #endless,d3
  294. X         qdos     sd.bordr
  295. X*
  296. Xnobar    bsr.s    read
  297. Xnwrite   bsr.s    write
  298. X         tst.b    d5
  299. X         bne.s    end_
  300. X         bsr.s    read
  301. X         bsr.s    more
  302. X         bra.s    nwrite
  303. Xend_     move.l   offset(a6),proffs(a6)
  304. X         bsr.s    more
  305. Xno       moveq    #0,d0
  306. Xrjob     moveq    #-1,d1
  307. X         qdos     mt.frjob
  308. X         bra      rjob
  309. X*
  310. Xread     move.l   a3,a0             input channel
  311. X         moveq    #0,d7             index
  312. X         moveq    #0,d6             line
  313. X         moveq    #80,d2
  314. Xrloop    lea      buffer(a6,d7.w),a1
  315. X         qdos     io.fline
  316. X         tst.w    d1
  317. X         seq      d5
  318. X         beq.s    rend
  319. X         add.w    d1,d7
  320. X         addq.w   #1,d6
  321. X         cmp.w    #21,d6
  322. X         bmi      rloop
  323. Xrend     ext.l    d7
  324. X         move.l   offset(a6),proffs(a6)
  325. X         add.l    d7,offset(a6)
  326. X         rts
  327. X*
  328. Xwrite    move.l   a4,a0             output channel
  329. X         qdos     sd.clear
  330. X         lea      buffer(a6),a1
  331. X         move.w   d7,d2
  332. X         qdos     io.sstrg
  333. X         tst.l    d0
  334. X         bmi      rjob
  335. X         rts
  336. X*
  337. Xmore     move.l   a5,a0             scrollbar
  338. X         move.l   filelen(a6),d0
  339. X         beq.s    noflen
  340. X         move.l   proffs(a6),d4
  341. X         beq.s    noflen
  342. X         divu     d0,d4
  343. X         beq.s    noflen
  344. X         lea      block(a6),a1
  345. X         move.w   d4,2(a1)
  346. X         moveq    #7,d1
  347. X         qdos     sd.fill
  348. X*
  349. Xnoflen   move.l   a4,a0
  350. X         moveq    #79,d1
  351. X         moveq    #20,d2
  352. X         qdos     sd.pos
  353. X         qdos     sd.cure
  354. X         qdos     io.fbyte
  355. X         move.b   d1,d4
  356. X         qdos     sd.curs
  357. X         cmp.b    #'n',d4
  358. X         beq      no
  359. X         cmp.b    #'q',d4
  360. X         beq      no
  361. X         rts
  362. X*
  363. X         end
  364. X
  365. END_OF_FILE
  366.   if test 4929 -ne `wc -c <'more.asm'`; then
  367.     echo shar: \"'more.asm'\" unpacked with wrong size!
  368.   fi
  369.   # end of 'more.asm'
  370. fi
  371. if test -f 'unquill.c' -a "${1}" != "-c" ; then 
  372.   echo shar: Will not clobber existing file \"'unquill.c'\"
  373. else
  374.   echo shar: Extracting \"'unquill.c'\" \(1221 characters\)
  375.   sed "s/^X//" >'unquill.c' <<'END_OF_FILE'
  376. X#include <stdio.h>
  377. X
  378. X/* usage: ex unquill,from,to */
  379. X
  380. Xchar _prog_name[] = "unquill";
  381. X
  382. Xlong main()
  383. X{
  384. X    register int    linelen, wordlen;
  385. X    register int    c;
  386. X    char     word[256];
  387. X    char     *wp;
  388. X
  389. X    wp      = word;
  390. X    linelen = wordlen = 0;
  391. X
  392. X    while((c = getchar()) != EOF)
  393. X    {
  394. X        switch(c)
  395. X        {
  396. X            case(0x9):
  397. X            case(' '):
  398. X                if((linelen += (wordlen + 1)) < 78)
  399. X                {
  400. X                    *wp     = 0;
  401. X                    printf("%s ", word);
  402. X                    wordlen = 0;
  403. X                    wp      = word;
  404. X                }
  405. X                else
  406. X                {
  407. X                    *wp = 0;
  408. X                    printf("\n%s ", word);
  409. X                    linelen = wordlen + 1;
  410. X                    wordlen = 0;
  411. X                    wp = word;
  412. X                }
  413. X                break;
  414. X
  415. X            case(0x0):
  416. X                *wp = 0,
  417. X                printf("%s\n", word);
  418. X                linelen = wordlen = 0;
  419. X                wp = word;
  420. X                break;
  421. X
  422. X            default:
  423. X            {
  424. X                if(c > ' ')
  425. X                    *wp++ = c, ++wordlen;
  426. X                break;
  427. X            }
  428. X        }
  429. X    }
  430. X    puts("");
  431. X    return(0);
  432. X}
  433. END_OF_FILE
  434.   if test 1221 -ne `wc -c <'unquill.c'`; then
  435.     echo shar: \"'unquill.c'\" unpacked with wrong size!
  436.   fi
  437.   # end of 'unquill.c'
  438. fi
  439. echo shar: End of archive.
  440. exit 0
  441. exit 0 # Just in case...
  442.